home *** CD-ROM | disk | FTP | other *** search
- // •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
- // Messages.h
- //
- // July 31, 1996
- // By Ben Manuto
- //
- // © 1996 by Apple Computer, Inc., all rights reserved.
- //
- // This file contains constants and specially defined paramblocks for use with the
- // messaging system as well as the Universal procedure definitions for PPC programming.
- //
- // •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
-
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
-
-
- #define kDriverName "\p.Symbiosis" // The name of the driver
-
-
- // •••••••••• ParamBlockRec for .Symbiosis driver.
-
- typedef struct {
- QElemPtr qLink; // queue link in header
- SInt16 qType; // type byte for safety check
- SInt16 ioTrap; // not used for messaging.
- Ptr ioCmdAddr; // not used for messaging.
- ProcPtr ioCompletion; // completion routine addr (0 for synch calls)
- OSErr ioResult; // result code
- StringPtr ioNamePtr; // not used for messaging.
- SInt16 ioVRefNum; // not used for messaging.
- SInt16 ioCRefNum; // refNum for I/O operation
- SInt16 csCode; // The operation code
- void * csPtr; // pointer to procedure or data
- SInt32 csData; // data
- SInt32 csData2; // data
- } SBParamBlockRec, *SBParamBlockRecPtr; // 'SB' for 'S'ym'B'iosis
-
-
- // •••••••••• Message Universal Procedure Pointers
-
- #if GENERATINGCFM
- typedef UniversalProcPtr MsgCompletionUPP;
- typedef UniversalProcPtr MsgReceiveUPP;
- #else
- typedef ProcPtr MsgCompletionUPP;
- typedef ProcPtr MsgReceiveUPP;
- #endif
-
-
- // •••••••••• Message control codes
-
- enum {
- eSendMessage = 800, // Send a message
- eInstallMsgHandler = 801, // Install a message handler
- eRemoveMsgHandler = 802, // Remove message handler
- eRegisterMessage = 803 // Register message type
- };
-
-
- // •••••••••• Message Results (in msgResult field of MsgPBlk)
-
- enum {
- msgNoError = 0, // No error, completed
- msgOverrun = -1, // More data was available
- msgUnderrun = -2, // Less data was available
- msgTimeout = -3 // Timeout error
- };
-
-
- // •••••••••• Message Parameter block.
-
- typedef struct MsgPBlk {
- struct MsgPBlk* msgQLink; // Pointer to next queue element
- SInt16 msgQType; // Queue Flags
- SInt16 msgCmd; // The message type or command
- SInt32 msgParam1; // Message parameter 1
- SInt32 msgParam2; // Message parameter 2
- void* msgBuffer; // Ptr to the message data buffer
- SInt32 msgReqCount; // Requested data length
- SInt32 msgActCount; // Actual data length
- MsgCompletionUPP msgCompletion; // Ptr to completion routine or NULL
- SInt16 msgResult; // The result of message operation
- UInt16 msgFlags; // Message flags (swap and shared)
- UInt32 msgUserData; // For use by caller (a5, etc…)
- } MsgPBlk, *MsgPBlkPtr;
-
-
- // •••••••••• Message Record Element.
-
- typedef struct MsgRecElem {
- struct MsgRecElem* recQLink; // Next queue element
- SInt16 recQType; // queue flags
- SInt16 recFlags; // Not used...Set to zero
- MsgReceiveUPP recProc; // Ptr to the receive procedure
- SInt16 recCmdBase; // first command received by this proc
- SInt16 recCmdCount; // # of commands allocated for this proc
- UInt32 recUserData; // For caller's use (could be A5...)
- } MsgRecElem, *MsgRecElemPtr;
-
-
- // •••••••••• Message Universal Procedure Information
-
- enum {
- uppMsgReceiveProcInfo = kRegisterBased
- | REGISTER_ROUTINE_PARAMETER(1, kRegisterA1, SIZE_CODE(sizeof(MsgRecElemPtr)))
- | REGISTER_ROUTINE_PARAMETER(2, kRegisterD0, SIZE_CODE(sizeof(SInt16)))
- | REGISTER_ROUTINE_PARAMETER(3, kRegisterD1, SIZE_CODE(sizeof(SInt32)))
- | REGISTER_ROUTINE_PARAMETER(4, kRegisterD2, SIZE_CODE(sizeof(SInt32)))
- | REGISTER_RESULT_LOCATION(kRegisterA0)
- | RESULT_SIZE(kFourByteCode),
-
- uppMsgCompletionProcInfo = kRegisterBased
- | REGISTER_ROUTINE_PARAMETER(1, kRegisterA0, SIZE_CODE(sizeof(MsgPBlkPtr)))
- | REGISTER_RESULT_LOCATION(kRegisterA0)
- | RESULT_SIZE(kFourByteCode)
- };
-
-
- // •••••••••• Message Universal Procedure Pointer Creation Macros
-
- #if GENERATINGCFM
- #define NewMsgReceiveProc(userRoutine) \
- (MsgReceiveUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppMsgReceiveProcInfo, GetCurrentArchitecture())
- #else
- #define NewMsgReceiveProc(userRoutine) \
- ((MsgReceiveUPP) (userRoutine))
- #endif
-
- #if GENERATINGCFM
- #define NewMsgCompletionProc(userRoutine) \
- (MsgCompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppMsgCompletionProcInfo, GetCurrentArchitecture())
- #else
- #define NewMsgCompletionProc(userRoutine) \
- ((MsgCompletionUPP) (userRoutine))
- #endif
-
-
-